package com.audaque.springboot.foshanupload.core.util.ssl.model;

import java.io.Serializable;
import java.util.regex.Pattern;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;

public class RegexHostnameVerifier implements HostnameVerifier, Serializable {
    private static final long serialVersionUID = 1L;
    private final Pattern pattern;

    public RegexHostnameVerifier(final String regex) {
        this.pattern = Pattern.compile(regex);
    }

    public boolean verify(final String hostname, final SSLSession session) {
        return this.pattern.matcher(hostname).matches();
    }
}
